﻿var  panel_list;
{
    	Ext.regModel('data', { fields:['code','name'] });
        
        var objProxy = new Ext.data.AjaxProxy({
            // url: './url/list1.asp',
            type:'ajax',
            // model:'sampleData1',
            reader:{
                type:'json',
                code:"code",
                name:"name",
                root:'data'
            }
        });
        var objStore = new Ext.data.JsonStore({
        	// url: 'bbb.asp',
        	fields:[ {name:'code', type:'string'}, {name:'name', type:'string'} ],
            // autoLoad:true,-- 흠냐..
            // listeners:objStoreListener,
            proxy: objProxy
        });	   
        // alert('hi3');
        // objStore.load();
        // alert('hi4');
    	objList = new Ext.List({
    		store:objStore,
    		SelectedItemCls:'x-list-over',
    		onItemDisclosure:true,
    		itemTpl:'<div class="contact"><strong>{name}</strong>,{code}</div>',
    	});
    	// alert('hi5');
    	
    	/*
		 * objList.on("disclose", function(record, btn, index) {
		 * Ext.Msg.alert('Tap','Disclose more info for' + record.get('name'),
		 * Ext.emptyFn); });
		 */		
    	objList.bindStore(objStore);
    	// objList.store = objStore;
    	// objList.show(this);
    	// alert('hi6' + objList);
         panel_list = new Ext.form.FormPanel({
   			// fullscreen:true,
   			useCurrentLocation: true,   			
    		scroll:'vertical',
			cardSwitchAnimation:"slide",
		    layout: {
		        type: 'vbox',
		        pack: 'center',
		        align: 'stretch'
		    },
		    scroll: 'vertical',
    		listeners:FormListener,		         	            
    		items: [{ 
    			xtype: 'fieldset',
                title: '영업점 조회',
                // instructions: '영업점명을 입력하시고 조회버튼을 클릭하십시요',
                defaults: {
                    required: true,
                    labelAlign: 'left' 
                } ,
    			items:[{
					layout: {
						type: 'hbox',
						pack: 'center',
					},  
					// flex: 2, style: 'margin: .5em;',
    				items:[{
	    				xtype:'textfield',
	    				name:'userid',
	    				// label:'영업점코드',
	    				width:'50%',
	    				placeHolder:'영업점코드',
	    				autoCapitalisze:true,
	    				useClearIcon:false
	    			},{
	    				xtype:'spacer',
	    				width:'10%',
	    			},{
	    				xtype:'button',
	    				ui: 'decline-round',
	    				name:'button_search',
	    				width:'30%',
			            handler:function(){    				
		            		createList();	
			            },	    				
			            // iconCls: 'cancel',
			            // iconAlign: 'left',
			            // iconMask:true,
	    				text:'조회'
					}]	    				    			
    			}]
    		}, {
            	xtype: 'fieldset',
                // title: '영업점리스트',
                instructions: '상세정보를 보고 싶으시면 영업점리스트를 클릭하십시요',
                // fullscreen:true,
                // layout:'fit',
                defaults: {labelAlign: 'left' }, items:objList } ],
                click_login:function(){
    			// Alert('hi activate');
    		}    		
    	}); 

		var FormListener = {
			activate:function() {
				// alert('activate');
			}, load:function() {
					// alert('load');
			}
		}

		var objList;
		function createList()
		{
	    	// alert('hi1');
	        objProxy = new Ext.data.AjaxProxy({
	            url: './url/list2.asp',
	            type:'ajax',
	            encode: 'euc-kr',
	            // model:'sampleData1',
	            reader:{
	                type:'json',
	                // totalProperty:"total",
	                // callback:'aaa',
	                code:"code",
	                name:"name",
	                root:'data'
	            }
	        });	        
	        var objStore        = new Ext.data.JsonStore({
	        	// url: 'bbb.asp',
	        	encode: 'true',
	        	fields:[
	        		{name:'code', type:'string'},
	        		{name:'name', type:'string'}
	        	],
	            // autoLoad:true,
	            // listeners:objStoreListener,
	            proxy: objProxy
	        });	   
	        // alert('hi3');
	        objStore.load(); 	
	        /*
			 * //alert('hi4'); objList = new Ext.List({ store:objStore,
			 * selectedItemCls:'x-list-over', onItemDisclosure:true, itemTpl:'<div
			 * class="contact"><strong>{name}</strong>,{code}</div>', });
			 */
	    	// alert('hi5');
	    	/*
			 * objList.on("disclose", function(record, btn, index) {
			 * Ext.Msg.alert('Tap','Disclose more info for' +
			 * record.get('name'), Ext.emptyFn); });
			 */		
	    	objList.bindStore(objStore);
	    	// objList.store = objStore;
	    	// objList.show(this);
	    	
	    	// alert('hi6' + objList);
	    		            	
		}
}		